﻿using Pepper.Temple.WPF.Core.Constants.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pepper.Temple.WPF.Core.Models
{
    public class Result<T>
    {
        public T Data { get; set; }

        public bool Succeed { get; set; }

        public string Message { get; set; }

        public ErrorCode Code { get; set; }

        public static Result<T> Success(T data)
        {
            return new Result<T>()
            {
                Data = data,
                Succeed = true,
                Code = ErrorCode.Unknown,
                Message = "操作成功"
            };
        }

        public static Result<T> Fail(string message,ErrorCode code = ErrorCode.Unknown)
        {
            return new Result<T>()
            {
                Data = default(T),
                Succeed = false,
                Code = code,
                Message = message,
            };
        }
    }
}
